import {
    defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginImport from 'vite-plugin-babel-import';
import {
    viteMockServe
} from 'vite-plugin-mock'
import path from 'path'

const baseUrl = {
    development: './',
    beta: './',
    release: './'
}

export default ({
    mode
}) => defineConfig({
    plugins: [
        vue(),
        viteMockServe({
            mockPath: "./src/mock",
            supportTs: false
        }),
    ],
    base: baseUrl[mode],
    resolve: {
        alias: {
            '~': path.resolve(__dirname, './'),
            '@': path.resolve(__dirname, 'src')
        }
    },
    css: {
        preprocessorOptions: {
            scss: {
                // 主题样式
                additionalData: `@import "@/assets/css/them.scss";`
            }
        }
    },
    server: {
        host: '0.0.0.0',
        cors: true, // 默认启用并允许任何源
        // proxy: {
        //     '/api': {
        //         target: 'http://192.168.1.13',
        //         changeOrigin: true,
        //         rewrite: path => path.replace(/^\/api/, '')
        //     }
        // }
    }
})